import React from 'react'
import { Link } from 'react-router-dom'
import { Tag } from 'antd'
import GUtils from '@/utils'

export const couponChannelMap = {
  0: '',
  1: '美团',
  2: '点评',
  3: '抖音',
}
const Config = (Action) => {
  const columns = [
    {
      title: '订单编号',
      dataIndex: 'orderNo',
      width: 200,
      render(v, vo) {
        return (
          <div>
            <div>
              单号： <Link to={`detail/view?id=${vo.uid}`}>{v}</Link>
            </div>
            <div>下单时间：{GUtils.dateTimeFormatter(vo.createTime)}</div>
            <div>{vo.type == 2 && <Tag color="success">会员订单</Tag>}</div>
            <div>
              {vo?.couponChannel !== undefined &&
                vo?.couponChannel !== null &&
                couponChannelMap?.[vo?.couponChannel] && (
                  <Tag color="processing">
                    {couponChannelMap?.[vo?.couponChannel]}
                  </Tag>
                )}
            </div>
          </div>
        )
      },
    },
    {
      title: '门店名称',
      dataIndex: 'shopName',
      width: 140,
      render(v, vo) {
        return (
          <div>
            <div>{v}</div>
            {vo?.stationLabel && <Tag color="success">{vo?.stationLabel}</Tag>}
          </div>
        )
      },
    },
    {
      title: '产品信息',
      dataIndex: '产品信息',
      width: 180,
      render(v, vo) {
        return (
          <div>
            <div>
              起付金额：{vo.productStartPrice}元/{vo.productStartMinute}分钟
            </div>
            <div>分钟计价：{vo.productMinutePrice}元/分钟</div>
          </div>
        )
      },
    },
    {
      title: '用户信息',
      dataIndex: 'userId',
      width: 140,
      render(v, vo) {
        return (
          <div>
            <div>用户昵称：{vo.userNickname}</div>
            <div>用户ID：{vo.userId}</div>
            <div>手机：{vo.userPhone}</div>
          </div>
        )
      },
    },
    {
      title: '耗时',
      dataIndex: 'time',
      width: 220,
      render(v, vo) {
        return (
          <div>
            <div>开始时间：{GUtils.dateTimeFormatter(vo.startTime)}</div>
            <div>结束时间：{GUtils.dateTimeFormatter(vo.completedTime)}</div>
            <div>用时：{vo.useDurationStr || ''}</div>
          </div>
        )
      },
    },
    {
      title: '订单金额',
      dataIndex: 'totalAmount',
      width: 120,
      render(v, vo) {
        return (
          <div>
            <div>{GUtils.renderAmount(v)}</div>
            {vo.type == 2 && (
              <Tag title="会员抵扣" type="success">
                {GUtils.renderAmount(vo.vipDiscountAmount)}
              </Tag>
            )}
          </div>
        )
      },
    },
    {
      title: '订单状态',
      dataIndex: 'status',
      width: 70,
      render: (v, vo) => GUtils.renderWashOrderStatus(vo),
    },

    {
      title: '操作',
      dataIndex: 'id',
      width: 90,
      render(id, vo) {
        return (
          <div>
            <Link to={`detail/view?id=${vo.uid}`} className="mr-8">
              查看详情
            </Link>
          </div>
        )
      },
    },
  ]
  return {
    ...window.CONFIG.getPagerConfig(Action),
    columns,
  }
}

export default Config
